type
  Person = ref object of RootObj
    typeName: string
    name: string
  Student = ref object of Person
    level: int

method print(p:Person) = 
  echo p.typeName, ": ",  p.name

method print(s:Student) =
  echo s.typeName, ": ",  s.name, ", level: ", s.level

var p1:Person = Person(typeName:"person", name:"xiaomao")
var s1:Student = Student(typeName:"student", name:"damao", level:3)

var ps:Person = s1
print(ps)
# ps bind to Student although its type is Person
